import 'package:flutter/widgets.dart';

/// 提供键盘是否显示数据
class KeyboardVisibleProvider extends InheritedWidget {
  const KeyboardVisibleProvider({
    Key? key,
    required this.keyboardVisible,
    required Widget child,
  }) : super(key: key, child: child);

  final bool keyboardVisible;

  static bool isKeyboardVisible(BuildContext context) {
    return context
            .dependOnInheritedWidgetOfExactType<KeyboardVisibleProvider>()
            ?.keyboardVisible ??
        false;
  }

  @override
  bool updateShouldNotify(KeyboardVisibleProvider oldWidget) {
    return keyboardVisible != oldWidget.keyboardVisible;
  }
}
